#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "gps.h"
#include "gps_boat.h"
#include <unistd.h>
#include <sys/types.h>
#include <pthread.h>

gps_data_t my_gps_data;

int gps_connect()
{
    int ret = gps_open("localhost", "2947", &my_gps_data);

    (void) gps_stream(&my_gps_data, WATCH_ENABLE | WATCH_JSON, NULL);

/*    while (1){
	    usleep(100000);

	    if (gps_waiting (&gps_data, 500)) {
		errno = 0;
		if ( == -1) {
		    fprintf(stderr, "GPS Error.\n");
		} else {
		    // Display data from the GPS receiver. 
		    //if (gps_data.set & ...
		}
	    }

    }
     When you are done... */


    return 0;
}


gps_data_t gps_fetch()
{
	gps_read(&my_gps_data);
	return my_gps_data;
}

void gps_disconnect()
{    
	(void) gps_stream(&my_gps_data, WATCH_DISABLE, NULL);
	(void) gps_close (&my_gps_data);
}
